#!/usr/bin/python
"""
testy_test.py: Tests for testy.py
"""

__author__ = 'Andy Chu'


import os
import sys
import unittest

if __name__ == '__main__':
  sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '../..'))

import log
import testy  # module under test


class ExampleTest(testy.Test):

  def testPassing(self):
    """A passing test."""
    self.verify.Equal(1, 1)


class RealTest(testy.Test):
  """This is an actual test for testy, not data for the test."""

  def setUp(self):
    pass

  def tearDown(self):
    pass

  def testSimple(self):
    #mylog = log.Logger()
    mylog = log.NullLogger()  # For now, silence it
    result = testy.RunTests([ExampleTest()], log=mylog)

    # TODO: result should be a JSON object, have result.success == True, as well
    # as a list of failures and errors
    self.verify.Equal(result, True)

  def testLoadingTestData(self):
    data = self.data.Bytes('bytes.txt')
    self.verify.Equal(data, 'foo\nbar\n')

    # Test string
    data = self.data.String('bytes.txt')
    self.verify.Equal(data, u'foo\nbar\n')
    self.verify.Equal(type(data), unicode)


if __name__ == '__main__':
  success = testy.RunTests([RealTest()])
  sys.exit(not success)
